package com.xianyu.ssoserver.repository.customer;

import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import javax.persistence.EntityManager;
import java.io.Serializable;

/**
 * <p>自定义仓库实现.<br>
 *
 * @author 17070717.
 * @version 2017/11/6.
 */

public class CustomerRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> implements CustomerRepository<T, ID> {

    private EntityManager entityManager;

    public CustomerRepositoryImpl(Class<T> domainClass, EntityManager em) {
        super(domainClass, em);
        this.entityManager = em;
    }

    @Override
    public T queryByProperty(T entity) {
        return findOne(CustomerSpecification.byProperty(entityManager, entity));
    }
}
